from department.models import DepartmentRole, DepartmentEmpower


def department_role_view(department_role):
    assert isinstance(department_role, DepartmentRole)
    view = {
        'rid': department_role.id,
        'name': department_role.name,
        'did': department_role.did_id,
        'permissions': [empower.pid_id for empower in DepartmentEmpower.objects.filter(rid=department_role)]
    }
    return view
